<template>
	<view>
		<zy-title rightText="保存" @right="requestSave"></zy-title>
		
		<view class="zy-page-padding">
			<view class="zy-text-white-lg-bold zy-mt-lg" style="font-size: 42rpx;">{{title}}</view>
			<view class="zy-mt-lg">
				<input class="zy-pv-lg zy-text-whitegrey" placeholder="请输入" v-model="content"/>
			</view>
			<zy-line></zy-line>
		</view>
		
	</view>
</template>

<script>
	import RouteUtil from '@/main/common/RouteUtil';
	export default {
		data() {
			return {
				title: '',
				content: '',
				type:1,
			}
		},
		onLoad(options) {
			this.type = options.type;
			if(options.content){
				this.content = options.content;
			}
			if(1 == this.type){
				this.title = '修改昵称';
			}else if(2 == this.type){
				this.title = '修改微信';
			}else if(3 == this.type){
				this.title = '修改个性签名';
			}
		},
		methods: {
			requestSave(){
				if(this.content == ''){
					uni.$toast.showToast('请输入')
					return
				}
				let params = {};
				if(1 == this.type){
					params.nick = this.content;
				}else if(2 == this.type){
					params.weChat = this.content;
				}else if(3 == this.type){
					params.sign = this.content;
				}
				uni.$http.updateUser(params).then(res => {
					uni.$toast.showToast('保存成功')
					uni.$emit('sendContent', {type: this.type, content: this.content})
					RouteUtil.back()
					if(1 == this.type){
						CacheUtil.setUserName(nick)
					}
				})
			}
		}
	}
</script>

<style>

</style>
